package com.lesama.method;

/*
    线程方法：
        static void sleep(long time) 让线程休眠指定的时间，单位为毫秒
        setPriority(int newPriority) 设置线程的优先级， 1为最高
        final int getPriority() 获取线程的优先级
        final void setDaemon(boolean on) 设置为守护线程
 */

public class ThreadMethodDemo1 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 5; i > 0; i--) {
                    System.out.println("倒计时" + i + "秒");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }, "线程1");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 5; i > 0; i--) {
                    System.out.println("倒计时" + i + "秒");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }, "线程2");
        t1.start();
        t2.start();
    }
}
